package com.wm.yigongfang.controller;

import com.wm.yigongfang.common.jwt.UserLoginToken;
import com.wm.yigongfang.common.web.Result;
import com.wm.yigongfang.common.web.Results;
import com.wm.yigongfang.dto.req.AddJobReq;
import com.wm.yigongfang.entity.Job;
import com.wm.yigongfang.entity.MachineType;
import com.wm.yigongfang.service.JobService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("app/job")
public class JobController {

    @Resource
    private JobService jobService;

    @GetMapping("machineTypeList")
    @UserLoginToken
    public Result<List<MachineType>> machineTypeList() {
        return Results.ok(jobService.machineTypeList());
    }

    @GetMapping("jobList")
    @UserLoginToken
    public Result<List<Job>> jobList() {
            return Results.ok(jobService.jobList());
    }

    @PostMapping("addJob")
    @UserLoginToken
    public Result<Void> addJob(@RequestBody @Validated AddJobReq req) {
        jobService.addJob(req);
        return Results.ok();
    }


}
